
//
//  JYSettingPwdView.m
//  JYFarm
//
//  Created by 花花 on 2017/10/11.
//  Copyright © 2017年 花花. All rights reserved.
//

#import "JYSettingPwdView.h"

@interface JYSettingPwdView()<UITextFieldDelegate>
@property(nonatomic)UIView *line;


@end
@implementation JYSettingPwdView
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self initUI];
        [self initConstraint];
    }
    return self;
}

- (void)initUI{
    
    self.imgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
    [self addSubview:self.imgView];
    self.inputTextFiled = [UITextField new];
    self.inputTextFiled.leftViewMode = UITextFieldViewModeAlways;
    self.inputTextFiled.rightViewMode = UITextFieldViewModeNever;
    self.inputTextFiled.clearButtonMode = UITextFieldViewModeAlways;
    [self.inputTextFiled setValue:kFont(12) forKeyPath:@"_placeholderLabel.font"];
    self.inputTextFiled.font = kFont(14);
    self.inputTextFiled.delegate = self;
//    self.inputTextFiled.secureTextEntry = YES;
    self.inputTextFiled.returnKeyType = UIReturnKeyDone;
    [self addSubview:self.inputTextFiled];
    

    
    self.line = [UIView new];
    self.line.backgroundColor = kThemeColor;
    
    [self addSubview:self.line];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [textField resignFirstResponder];
    
    return YES;
    
}
- (void)initConstraint{
    
    CGFloat margin = 20;
    JYWeakSelf;
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(margin);
        make.height.width.mas_equalTo(20);
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
    }];
    [self.inputTextFiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.imgView.mas_right).offset(10);
        make.right.equalTo(self).mas_offset(0);
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
    }];
    
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.bottom.equalTo(self);
        make.height.equalTo(@(1));
    }];
}

@end
